﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RRHH.Entities;
using System.Data.SqlClient;
using System.Data;

namespace RRHH.DataAccess
{
    public class DAOCentroCosto
    {
        public List<BECentroCosto> ListarCentroCosto()
        {

            string sql = "SP_LISTAR_CENTROCOSTO";

            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = sql;

            using (DataAccess adoDataService = new DataAccess())
            {

                List<BECentroCosto> _BLCentroCosto = new List<BECentroCosto>();
                IDataReader dr = adoDataService.ExecuteReader(sqlCommand);

                while (dr.Read())
                {
                    BECentroCosto _BECentroCosto = new BECentroCosto();
                    _BECentroCosto.idCentroCosto = Convert.ToInt32(dr["IDCENTROCOSTO"]);
                    _BECentroCosto.descripcion = Convert.ToString(dr["DESCRIPCION"]);
                    _BECentroCosto.estado = Convert.ToString(dr["ESTADO"]);
                    _BLCentroCosto.Add(_BECentroCosto);
                }
                dr.Close();

                adoDataService.Dispose();

                return _BLCentroCosto;
            }

        }
    }
}
